<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

get_header(); ?>
<?php
    while(have_posts()) {
        
        $id = $_GET['p'];
    
        // vypis projektu
        if (get_post_meta($id, 'project', true) == 1) {
            $project = $vtpProjects->getProjectByPostId($id);
            // begin post
            echo '<div class="project-item-container">';
            echo '<div class="project-item-content">';
            echo '<div class="project-item-imgwrap">';
            the_post();
            jr_post_image($id, 'medium');
            echo '</div>';            
            echo '<span class="project-item-title-wrapper">';
            
            echo '<span class="project-item-title">'; the_title(); echo '</span>';
            echo '<span class="index-post-item-details">';
            the_time('j. n. Y');
            echo ' / ';
            the_author();
            echo '&nbsp;&nbsp;prečítané: ';
            the_views();
            echo '</span>';
            echo '</span>';

            echo $project->perex.'<br /><br />'.$project->text;
            
            echo '<table class="project-item-table">';
            echo '<tr>';
            echo '<td><b>Kontaktný email:</b></td>';
            echo '<td><b>Dôležité linky:</b></td>';
            echo '</tr>';
            echo '<tr>';
            echo '<td><a class="project-item-link" href="mailto:'.$project->email.'">'.$project->email.'</td>';
            if ($project->link1 != '')
                echo '<td><a target=_blank class="project-item-link" href="'.$project->link1.'">'.$project->link1.'</a></td>';
            echo '</tr>';
            if ($project->link2 != '')
                echo '<tr><td></td><td><a target=_blank class="project-item-link" href="'.$project->link2.'">'.$project->link2.'</a></td></tr>';
            if ($project->link3 != '')
                echo '<tr><td></td><td><a target=_blank class="project-item-link" href="'.$project->link3.'">'.$project->link3.'</a></td></tr>';
            echo '</table>';

            echo '</div>';
            echo '</div>';
            
        }
        
        // partneri
        else if (get_post_meta($id, 'partner', true) == 1) {
            $partner = $vtpPartners->getPartnerByPostId($id);
            // begin post
            echo '<div class="partner-item-container">';
            echo '<div class="partner-item-content">';
            echo '<div class="partner-item-imgwrap">';
            the_post();
            jr_post_image($id, 'medium');
            echo '</div>';            
            echo '<span class="partner-item-title-wrapper">';
            
            echo '<span class="partner-item-title">'; the_title(); echo '</span>';
            echo '<span class="index-post-item-details">';
            the_time('j. n. Y');
            echo ' / ';
            the_author();
            echo '&nbsp;&nbsp;prečítané: ';
            the_views();
            echo '</span>';
            echo '</span>';
            
            echo '<span class="partner-item-text">'.$partner->activity.'</span>';
            
            echo '<table class="partner-item-table">';
            echo '<tr>';
            echo '<td><b>Kontaktný email:</b></td>';
            echo '<td><b>Telefonický kontakt:</b></td>';
            echo '</tr>';
            echo '<tr>';
            echo '<td><a class="partner-item-link" href="mailto:'.$partner->email.'">'.$partner->email.'</td>';
            if ($partner->phone1 != '')
                echo '<td>'.$partner->phone1.'</td>';
            echo '</tr>';
            if ($partner->phone2 != '')
                echo '<tr><td></td><td>'.$partner->phone2.'</td></tr>';
            if ($partner->phone3 != '')
                echo '<tr><td></td><td>'.$partner->phone3.'</td></tr>';
                
            echo '<tr><td>&nbsp;</td></tr>';
            echo '<tr>';
            echo '<td><b>Web:</b></td>';
            echo '<td><b>Fax:</b></td>';
            echo '</tr>';
            echo '<tr>';
            if ($partner->web != '')
                echo '<td><a class="partner-item-link" href="mailto:'.$partner->web.'">'.$partner->web.'</td>';
            if ($partner->phone1 != '')
                echo '<td>'.$partner->fax.'</td>';
            echo '</tr>';

            echo '<tr><td>&nbsp;</td></tr>';
            echo '<tr>';
            echo '<td><b>Alternatívny kontakt:</b></td>';
            echo '</tr>';
            echo '<tr>';
            echo '<td><span>Icq:</span> '.$partner->icq.'</td>';
            echo '<td><span>Skype:</span> '.$partner->skype.'</td>';
            echo '</tr>';                
            echo '<tr>';
            echo '<td><span>Gtalk:</span> '.$partner->gtalk.'</td>';
            echo '<td><span>Jabber:</span> '.$partner->jabber.'</td>';            
            echo '</tr>';
            echo '<tr>';
            echo '<td><span>Msn:</span> '.$partner->msn.'</td>';            
            echo '</tr>';
            echo '</table>';

            echo '</div>';
            echo '</div>';
               
        }

        // novinky
        else {
            echo '<h2>Novinky</h2>';

            // begin post
            echo '<div class="post-item-container">';
            echo '<div class="post-item-content">';
            echo '<div class="post-item-imgwrap">';
            the_post();
            jr_post_image($id, 'medium');
            echo '</div>';            
            echo '<span class="post-item-title-wrapper">';
            
            echo '<span class="post-item-title">'; the_title(); echo '</span>';
            echo '<span class="index-post-item-details">';
            the_time('j. n. Y');
            echo ' / ';
            the_author();
            echo '&nbsp;&nbsp;prečítané: ';
            the_views();
            echo '</span>';
            echo '</span>';

            the_content();
            echo '</span>';
            echo '</div>';
            echo '</div>';
                        
            // title, date & details
//            $timeStamp = get_post_time();
//            $monthYear = date('M y', $timeStamp);
//            $day = date('d', $timeStamp);            
//            echo '<span class="post-item-date">';
//            echo $monthYear.'<p>'.$day.'</p>';
//            echo '<ul class="addtoany_list">'; if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); echo '</ul>';
//            echo '</span>';            
//            echo '<span class="post-item-title">'; the_title(); echo '</span>';
//            echo '<span class="index-post-item-details">autor: <b>';
//            the_author();
//            echo '</b>&nbsp;&nbsp;prečítané: <b>';
//            the_views();
//            echo '</b></span>';
//            echo '</span>';
        }
        echo '<hr class="post-bottom-hr" />';

        echo '<div class="post-share">';
        if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON();
        echo '</div>';

        $back = $_SERVER['HTTP_REFERER'];
        if((isset($back) && $back !='')) {
            echo '<a class="post-item-goback" href="'.$back.'">&gt; Späť na predošlú stránku</a>';
        }
        
    }
?>
<?php get_footer(); ?>
